﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Draco.OWF.DataBinding
{
    public interface IBindingDataItemSchemaCollection : IList<IBindingDataItemSchema>
    {
        new void Add(IBindingDataItemSchema item);
        bool Contains(String dataName);
    }
    public class BindingDataItemSchemaCollection : List<IBindingDataItemSchema>, IBindingDataItemSchemaCollection
    {
        public new void Add(IBindingDataItemSchema item)
        {
            if (item != null && !Contains(item.DataName))
                base.Add(item);
        }

        public bool Contains(String dataName)
        {
            for (int i = 0; i < this.Count; i++)
            {
                if (String.Compare(this[i].DataName, dataName, true) == 0)
                    return true;
            }
            return false;
        }
    }

    public interface IBindingDataItemCollection : IList<IBindingDataItem>
    {
        new void Add(IBindingDataItem item);
        bool Contains(String dataName);
    }
    public class BindingDataItemCollection : List<IBindingDataItem>, IBindingDataItemCollection
    {
        public new void Add(IBindingDataItem item)
        {
            if (item!=null && !Contains(item.DataName))
                base.Add(item);
        }

        public bool Contains(String dataName)
        {
            for (int i = 0; i < this.Count; i++)
            {
                if (String.Compare(this[i].DataName,dataName,true)==0)
                    return true;
            }
            return false;
        }
    }
}
